<!--预警详情-->
<template>
    <div class="warnInfo">
        <div class="demo-tabs">
            <el-tabs v-model="state.tabsVal" @tab-click="handleClick">
                <el-tab-pane label="已处理" name="handle"></el-tab-pane>
                <el-tab-pane label="未处理" name="notHandle"></el-tab-pane>
            </el-tabs>
            <el-select v-model="state.selectVal" class="m-2">
                <el-option v-for="item in state.selectData" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
        </div>

        <div class="warnInfo_content">
            <div ref="elWarInfo"></div>
            <component :is="modalView" :tip="state.tabsVal"></component>
            <div class="pageFixClass">
                <el-pagination
                    v-model:currentPage="currentPage"
                    class="customPageClass"
                    :page-size="1"
                    small
                    :background="true"
                    :total="10"
                ></el-pagination>
            </div>
        </div>
    </div>
</template>
<script setup lang="ts">
import { reactive, ref, onMounted, watch, markRaw } from 'vue';
import type { Component } from 'vue';
import type { TabsPaneContext } from 'element-plus';
import { CheckSiderView } from '@/store/index';
import { warningFireControl, warningSafetySpyTwo, warningSecurity, warningSecurityCheck, warningEnergy } from './index';

const store = CheckSiderView();
const elWarInfo = ref<HTMLElement | null>(null);
const modalView = ref<Component | null>(null);
const currentPage = ref(1);
const emit = defineEmits(['hiden']);

const state = reactive({
    tabsVal: 'handle',
    selectVal: 'OverView',
    selectData: [
        {
            value: 'SecurityCheck',
            label: '安监'
        },
        {
            value: 'OverView',
            label: '总览'
        },
        {
            value: 'Security',
            label: '安防'
        },
        {
            value: 'FireControl',
            label: '消防'
        },
        {
            value: 'Energy',
            label: '能源'
        }
    ]
});

/** tabPane 选中事件 */
const handleClick = (tab: TabsPaneContext) => {
    console.log(tab, 'tab');
};

//   ['GreenInitiative', renderWarningSafetySpyComponent],
//   ['GreenInitiativeWaterQuality', renderWarningSafetySpyComponent],
//   ['Emergency', renderWarningSafetySpyComponent],
//   ['Statistics', renderWarningSafetySpyComponent]

/** 底部菜单所对应的告警弹框组件 */
const views: { [key in string]: Component } = {
    OverView: warningSafetySpyTwo,
    SecurityCheck: warningSecurityCheck,
    Security: warningSecurity,
    FireControl: warningFireControl,
    Energy: warningEnergy
};

/** 监听底部菜单视图 */
watch(
    () => store.ViewStatus,
    (val: ViewSider.ViewStatus) => {
        modalView.value = markRaw(views[val]);
        state.selectVal = val;
    },
    {
        immediate: true
    }
);
/** 监听下拉框 */
watch(
    () => state.selectVal,
    (val: string) => {
        modalView.value = markRaw(views[val]);
    },
    {
        immediate: true
    }
);
</script>
<style scoped lang="scss">
.customPageClass {
    margin-top: 16px;
}

.demo-tabs {
    position: relative;
    .m-2 {
        position: absolute;
        right: 0;
        top: 0;
        width: 12%;
        ::v-deep(.select-trigger) {
            width: 100%;
        }
        ::v-deep(.el-input__inner) {
            color: rgba($color: #dfeef3, $alpha: 0.7);
            font-size: 12px;
        }
        ::v-deep(.el-input__wrapper) {
            background: rgba($color: #fff, $alpha: 0.12) !important;
            box-shadow: none;
        }
    }
    ::v-deep(.el-tabs__item) {
        color: #fff;
        font-size: 18px;
    }
    ::v-deep(.is-active) {
        color: #0e96ff;
    }
    ::v-deep(.el-tabs__nav-wrap::after) {
        background: rgba($color: #0e96ff, $alpha: 0.28);
    }
    ::v-deep(.el-tabs__active-bar) {
        background: #0e96ff;
    }
}
.warnInfo {
    padding: 15px 30px 20px 30px;
    box-sizing: border-box;
    .pageFixClass {
        width: 100%;
        display: flex;
        justify-content: flex-end;
    }
    &_content {
        display: flex;
        flex-wrap: wrap;
        ::v-deep(.el-scrollbar) {
            width: 100%;
        }
        ::v-deep(.el-scrollbar__view) {
            display: flex;
            flex-wrap: wrap;
        }
        ::v-deep(.warnTemplate) {
            width: calc(50% - 12px);
            margin-right: 24px;
            &:last-of-type {
                margin-bottom: auto;
            }
            &:nth-of-type(2n) {
                margin-right: 0;
            }
        }
    }
}
</style>
